package moon.core.classdef;

import moon.core.Name;
import moon.core.entity.InternalEntity;

/**
 * Local variable in a method.
 * 
 * @author <a href="mailto:rmartico@ubu.es">Ra&uacute;l Marticorena</a>
 *
 */
@SuppressWarnings("serial")
public abstract class LocalDec extends InternalEntity{
	
	/**
	 * Method that contains the local variable.
	 */
	private MethDec methDec;
	
	/**
	 * Constructor.
	 * 
	 * @param name name
	 * @param type type
	 */
	public LocalDec(Name name, Type type) {
		super(name, type);		
	} 

	/**
	 * 
	 * Implements abstract method NamedObject.getUniqueName.
	 * {@inheritDoc}
	 * 
	 * @return {@inheritDoc}
	 */
	@Override
	public Name getUniqueName() {
		return this.getMethDec().getUniqueName().concat("@" 
				+ this.getType().getUniqueName().toString() 
				+ ":" + this.getName().toString()
				+ "(" + this.getLine() + ")");		
	}

	/**
	 * Sets the method where the local variable appears.
	 * 
	 * @param methDec method
	 * @see #getMethDec
	 */
	public void setMethDec(MethDec methDec) {
		this.methDec = methDec;
	}

	/**
	 * Gets the method.
	 * 
	 * @return method
	 * @see #setMethDec
	 */
	public MethDec getMethDec() {
		return methDec;
	}
	
	/**
	 * {@inheritDoc}.
	 * 
	 * @return {@inheritDoc}
	 */
	public ClassDef getClassDef() {
		return methDec.getClassDef();
	}
	
} // LocalDec
